<template>
  <div class="exam-page">
    <g-empty v-if="list.length === 0" />
    <template v-else>
      <exam-card
        v-for="item in list"
        :key="item.id"
        :data="item"
        @click="toDetail(item)"
      />
    </template>
  </div>
</template>

<script>
import { getListByPage } from "./api";
import ExamCard from "./components/ExamCard.vue";

export default {
  components: {
    ExamCard
  },
  data() {
    return {
      list: [],
      loading: false
    };
  },
  onLoad() {
    this.loadMore();
  },
  methods: {
    async loadMore() {
      const list = await getListByPage();
      this.list = list;
    },
    toDetail(item) {
      this.$store.commit("setExam", item);
      this.toPage("/pages/exam/detail", { id: item.id });
    }
  }
};
</script>

<style lang="less">
@import "./index.less";
</style>
